#ifndef BITMAPINTERFACE_
#define BITMAPINTERFACE_

/*
 *  the color that is seen outside the "real" size of the bitmap
 * according to the standard placing a dot automatically considers the number
 * as a double (for float we need to put f as suffix)
 */
#define OUTSIDE_COLOR 0.5


#include "message.h"
#include "params.h"
// only include this for autocomplete features
#include "../lib/EasyBMP/EasyBMP.h"


class BitmapInterface {
private:
	Parameters* params;
	Message* message;
	
	int open_read;
	int has_errors;

	int real_height;
	int real_width;
	int local_height;
	int local_width;
	
	// the actual EasyBMP class that we use to open the bitmap :)
	BMP	workFile;
	
public:
	BitmapInterface(Message* msg, Parameters* par);
	
	// open for read or write
	void openForRead(const char* filename);
	// TODO: Separate
	void openForWrite(const char* filename);
	void writeFile(); // flush contents
	void writeFile(char* file); // flush contents
	
	// check for errors
	int hasErrors();

	// get/set height and width
	// real  = the real dimensions, stored in the bitmap file
	// local = the local dimensions, set because the bitmap has to fit a certain
	//         size e.g. height=8*k; width=8*m, when having 64 input neurons
	int getRealHeight();
	int getRealWidth();
	int getLocalHeight();
	int getLocalWidth();
	void setRealSize(int height, int width);
	void setLocalSize(int height, int width);
	
	// READING the bitmap
	// for monochrome, normalized (val/256)
	double getPixel(int x, int y);
	// for color stuff, normalized (val/256)
	double getPixelR(int x, int y);
	double getPixelG(int x, int y);
	double getPixelB(int x, int y);
	
	// WRITING the bitmap
	// for monochrome, normalized (val/256)
	void setPixel(int x, int y, double value);
	// for color stuff, normalized (val/256)
	void setPixelRGB(int x, int y, double red, double green, double blue);
};



#endif /*BITMAPINTERFACE_*/
